
import 'package:flutter/material.dart';
import 'package:flutter_ahj_app/base/pluglin/wxplulin/WxJumpUtils.dart';
import 'package:flutter_ahj_app/base/utils/ShowFiles/GetImageWidget.dart';
import 'package:flutter_ahj_app/base/values/SQColor.dart';

import 'package:url_launcher/url_launcher.dart';
// 弹窗dialog
class ShowDialogADDialog extends Dialog{
  var imageFile;
  var filePath;
  ShowDialogADDialog(this.imageFile,this.filePath);
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Material(
      //创建透明层
      type: MaterialType.transparency, //透明类型
      child: new Center(
        //保证控件居中效果
        child: new SizedBox(
          width: 300.0,
          height:600.0,
          child: Column(children: [
            GestureDetector(
              onTap: (){
                Navigator.pop(context);
                _launchURL(filePath);
              },
              child:Container(
                width:300,
                height:450,
                child: ImageWidget(fileName:imageFile,width: 300,height: 450,borderSize:0),
              ),
            ),

            Container(
              height: 75,
            ),
            GestureDetector(
              onTap: (){
                Navigator.pop(context);
              },
              child: Container(
                width: 40,
                height: 40,
                decoration:  BoxDecoration(//背景
                  color: Colors.white,
                  //设置四周圆角 角度
                  borderRadius: BorderRadius.all(Radius.circular(20.0)),
                ),
                child: Icon(Icons.close_sharp,color: SQColor.black_333333,),
              ),
            )
          ],
          ),
        ),
      ),
    );;
  }
  _launchURL(apkUrl) async {

    String httpUrl=apkUrl.toString();
    if(httpUrl.startsWith("wxsp")){
      WxJumpUtils.jumpWxSmallProgram(httpUrl);
    }else{
      if (await canLaunch(apkUrl)) {
        await launch(apkUrl);
      } else {
        throw 'Could not launch $apkUrl';
      }
    }


  }
}